package com.haoyu.number.sparsearr1025;

import java.util.Arrays;

/**
 * @author 蒿雨
 * @create 2021-10-26 9:01
 */
public class MaoPaoSort {
    public static void main(String[] args) {

        int arr[] = {9876543, 68, 5, 0, 874, 70000};
        //从小到大排序
        Arrays.sort(arr);
        for (int i : arr) {
            System.out.printf("%d\t", i);
        }
        System.out.println();

        //控制外层循环的次数
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] < arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        for (int i : arr) {
            System.out.printf("%d\t", i);
        }


    }
}
